import { ResPage, Mod } from "@/api/interface/index";
import { DEFAULT_SERVICE } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 模块管理模块
 */
// 获取模块列表
export const getModList = (params: { modId: string }) => {
  return http.post<ResPage<Mod.SysMod>>(DEFAULT_SERVICE + `/sysMod/getPage`, params);
};

// 获取模块详情
export const getModInfo = (params: { modId: string }) => {
  return http.post<Mod.SysModInfo>(DEFAULT_SERVICE + `/sysMod/getInfoById`, params);
};

// 新增模块
export const addMod = (params: { modId: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysMod/add`, params);
};

// 编辑模块
export const editMod = (params: { modId: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysMod/edit`, params);
};

// 删除模块
export const deleteMod = (params: { modId: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysMod/delete`, params);
};

// 获取模块字段列表
export const getModColumnList = (params: { modId: string }) => {
  return http.post<Array<Mod.SysModColumn>>(DEFAULT_SERVICE + `/sysModColumn/getList`, params);
};

// 新增模块字段
export const addModColumn = (params: { modId: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysModColumn/add`, params);
};

// 编辑模块字段
export const editModColumn = (params: { modId: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysModColumn/edit`, params);
};

// 删除模块字段
export const deleteModColumn = (params: { modId: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysModColumn/delete`, params);
};

//核心接口

// 获取模块数据列表
export const getModDataList = (params: { mid: string }) => {
  return http.post<Array<any>>(DEFAULT_SERVICE + `/sysModData/getList`, params);
};

// 获取模块数据列表
export const getModDataPage = (params: { mid: string }) => {
  return http.post<ResPage<any>>(DEFAULT_SERVICE + `/sysModData/getPage`, params);
};

// 新增模块数据
export const addModData = (params: { mid: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysModData/add`, params);
};

// 编辑模块数据
export const editModData = (params: { mid: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysModData/edit`, params);
};

// 删除模块数据
export const deleteModData = (params: { mid: string }) => {
  return http.post(DEFAULT_SERVICE + `/sysModData/delete`, params);
};

// 操作模块数据
export const fireModData = (params: Mod.FireInfo) => {
  return http.post(DEFAULT_SERVICE + `/sysModData/fire`, params);
};
